package com.example.cloudindex.web;

import com.example.cloudindex.entity.User;
import com.example.cloudindex.web.impl.OrderActionImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 1. feign 远程调用是发送的 post 请求
 * 2. 方法参数, 默认会转为body内容
 * 3. 对于简单类型(字符串, int) 可以通过 @RequestParam 标注, 实现传递
 *      @RequestParam 只需要在发送端标注,
 * 4. 对于复杂类型( 实体类 ), 必须在发送端和接收端都要标注
 */

@FeignClient(value = "cloud-order", fallback = OrderActionImpl.class)
public interface IOrderAction {

    @RequestMapping("order")
    String order();

    @RequestMapping("hello")
    String hello(@RequestParam String name);

    @RequestMapping("add")
    int add(@RequestParam int a, @RequestParam int b);

    @RequestMapping("user")
    User user(@RequestBody User user);


}
